/*
 * @Description:
 * @Author: maxyang
 * @Date: 2022-05-19 14:31:47
 * @LastEditTime: 2022-06-05 10:19:19
 * @LastEditors: liutq
 * @Reference:
 */
package announcement

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/maxyang107/jinglan/common"
	"github.com/maxyang107/jinglan/service"
)

/**
 * @description: 方法描述：获取公告列表
 * @Author: maxyang
 * @return {*}
 * @param {*gin.Context} c
 */
func GetAnnouncementList(c *gin.Context) {
	var announcementParam common.AnnouncementList

	if err := c.BindQuery(&announcementParam); err != nil {
		common.ResponseToJson(http.StatusOK, common.ParamError, err.Error(), c)
		return
	}

	al := service.AnnouncementService.GetAnnouncementList(announcementParam)
	common.ResponseListToJson(http.StatusOK, int(al.Page), int(al.PerPage), int(al.Total), al.Data, c)
}

/**
 * @description: 方法描述：获取公告详情
 * @Author: maxyang
 * @return {*}
 * @param {*gin.Context} c
 */
func GetAnnouncementDetail(c *gin.Context) {
	var param_ common.Detail

	if err := c.BindQuery(&param_); err != nil {
		common.ResponseToJson(http.StatusOK, common.ParamError, err.Error(), c)
		return
	}

	a := service.AnnouncementService.GetAnnouncementDetail(param_)
	common.ResponseDetailToJson(http.StatusOK, a, "success", c)
}
